package com.dt.platform.generator.module.oa;

import com.dt.platform.constants.db.OaTables;
import com.dt.platform.constants.enums.common.StatusEnableEnum;
import com.dt.platform.constants.enums.oa.ProjectUserRoleEnum;
import com.dt.platform.constants.enums.oa.ProjectUserStatusEnum;
import com.dt.platform.domain.oa.ProjectUser;
import com.dt.platform.domain.oa.meta.ProjectTaskMeta;
import com.dt.platform.domain.oa.meta.ProjectUserMeta;
import com.dt.platform.generator.config.Config;
import com.dt.platform.oa.page.ProjectUserPageController;
import com.dt.platform.proxy.oa.ProjectUserServiceProxy;
import com.github.foxnic.generator.builder.view.config.DatePickerType;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;

public class AProjectUserGtr extends BaseCodeGenerator {


    public AProjectUserGtr() {
        super(OaTables.OA_PROJECT_USER.$TABLE,"705020984087805957");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.view().field(OaTables.OA_PROJECT_USER.ID).basic().hidden(true);
        cfg.view().field(OaTables.OA_PROJECT_USER.PROJECT_ID).search().fuzzySearch();
        cfg.getPoClassFile().addSimpleProperty(Employee.class,"user","user","user");

        cfg.getPoClassFile().addSimpleProperty(String.class,"callMethod","callMethod","callMethod");


        cfg.getPoClassFile().addSimpleProperty(String.class,"taskRcdCount","taskRcdCount","taskRcdCount");
        cfg.getPoClassFile().addSimpleProperty(String.class,"workTimeTotal","workTimeTotal","workTimeTotal");

        cfg.getPoClassFile().addSimpleProperty(String.class,"taskCount","taskCount","taskCount");
        cfg.getPoClassFile().addSimpleProperty(String.class,"workRecord","workRecord","workRecord");

        cfg.getPoClassFile().addSimpleProperty(String.class,"taskActingCount","taskActingCount","taskActingCount");
        cfg.getPoClassFile().addSimpleProperty(String.class,"taskCompleteCount","taskCompleteCount","taskCompleteCount");
        cfg.getPoClassFile().addSimpleProperty(String.class,"taskCompletePct","taskCompletePct","taskCompletePct");
        cfg.getPoClassFile().addSimpleProperty(String.class,"taskRecord","taskRecord","taskRecord");



        cfg.view().field(ProjectUserMeta.WORK_TIME_TOTAL).basic().label("实际工时");
        cfg.view().field(ProjectUserMeta.TASK_RCD_COUNT).basic().label("记录总数");
        cfg.view().field(ProjectUserMeta.WORK_RECORD).basic().label("工作记录(记录/工时)");

        cfg.view().field(ProjectUserMeta.TASK_COMPLETE_COUNT).basic().label("已完成");
        cfg.view().field(ProjectUserMeta.TASK_ACTING_COUNT).basic().label("进行中");
        cfg.view().field(ProjectUserMeta.TASK_RECORD).basic().label("任务记录(进行中/已完成)");
        cfg.view().field(ProjectUserMeta.TASK_COMPLETE_PCT).basic().label("任务完成率");

        cfg.view().field(ProjectUserMeta.WORK_TIME_TOTAL).table().disable(true);
        cfg.view().field(ProjectUserMeta.TASK_RCD_COUNT).table().disable(true);
        cfg.view().field(ProjectUserMeta.TASK_COMPLETE_COUNT).table().disable(true);
        cfg.view().field(ProjectUserMeta.TASK_ACTING_COUNT).table().disable(true);


        cfg.view().search().inputLayout(
                new Object[]{
                        OaTables.OA_PROJECT_USER.STATUS,
                }
        );

        cfg.view().field(OaTables.OA_PROJECT_USER.UPDATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_USER.UPDATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_USER.CREATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_USER.CREATE_TIME).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_USER.PROJECT_ID).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_USER.OWN_TYPE).table().disable(true);
        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);
        cfg.view().form().labelWidth(88);
        cfg.view().field(OaTables.OA_PROJECT_USER.USER_ID).table().fillBy("user","name");
        cfg.view().field(OaTables.OA_PROJECT_USER.USER_ID).form().validate().required().form()
                .button().chooseEmployee(false);


        cfg.view().field(OaTables.OA_PROJECT_USER.STATUS).form().selectBox().enumType(ProjectUserStatusEnum.class);

        cfg.view().field(OaTables.OA_PROJECT_USER.ROLE).form().selectBox().enumType(ProjectUserRoleEnum.class);

        cfg.view().list().columnLayout(OaTables.OA_PROJECT_USER.USER_ID,OaTables.OA_PROJECT_USER.STATUS,ProjectUserMeta.WORK_RECORD,ProjectUserMeta.TASK_RECORD,ProjectUserMeta.TASK_COMPLETE_PCT,OaTables.OA_PROJECT_USER.IN_TIME,OaTables.OA_PROJECT_USER.OUT_TIME);

        cfg.view().field(OaTables.OA_PROJECT_USER.IN_TIME).form().dateInput().format("yyyy-MM-dd").type(DatePickerType.date).search().range();
        cfg.view().field(OaTables.OA_PROJECT_USER.OUT_TIME).form().dateInput().format("yyyy-MM-dd").type(DatePickerType.date).search().range();


        cfg.view().form().labelWidth(88);
        cfg.view().formWindow().bottomSpace(120);
        cfg.view().formWindow().width(Config.baseFormWidth_50);
        cfg.view().form().addGroup(null,
                new Object[] {
                        OaTables.OA_PROJECT_USER.USER_ID,
                }
        );

        cfg.view().list().operationColumn().addActionButton("移除","removeUser","remove-user");
        cfg.view().list().operationColumn().addActionButton("加入","addUser","add-user");

        cfg.view().list().addJsVariable("PAGE_TYPE","[[${pageType}]]","pageType");
        cfg.view().list().addJsVariable("PROJECT_ID","[[${projectId}]]","projectId");
        cfg.view().form().addJsVariable("PROJECT_ID","[[${projectId}]]","projectId");


        cfg.view().list().disableBatchDelete();
        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE)
                .setExtendJsFile(WriteMode.IGNORE); //列表HTML页


        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        AProjectUserGtr g=new AProjectUserGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
//        g.removeByBatchId("471622036347682816");
        //生成菜单
        //g.generateMenu(ProjectUserServiceProxy.class, ProjectUserPageController.class);
    }

}
